<?php
/**
 * @title 31. 下一个排列 -
 * @author start2004
 */

class Solution {

    /**
     * @param Integer[] $nums
     * @return NULL
     */
    function nextPermutation(&$nums) {
        /**
         * @since 2020-11-10 长度
         */
        $len = count($nums);

        /**
         * @since 2020-11-10 只有1个元素
         */
        if($len == 1){
            return $nums;
        } else {}

        /**
         * @since 2020-11-10 字典排序
         */
        self::find($nums, 0, $len-1);

        /**
         * @return
         */
        return $nums;
    }

    /**
     * @title 返回字典排序
     * @author start2004
     * @since 2020-11-10 Created
     *
     * @param array $num
     * @param int $left
     * @param int $right
     */
    public function find(&$num = [], $left = 0, $right = 0){
        /**
         * @since 2020-11-10 找到第一个升序点最长点
         */
        for($i=$left; $i<$right; $i++){
            if($nums[$i] <= $nums[$i+1]){
            } else {}
        }
    }
}




/**
 * @url http://127.0.0.1/leetcode/202007/2020.07.03_7.php
 */
$datas = [
    [1,2,3], // 1,3,2
    [3,2,1], // 1,2,3
    [1,1,5], // 1,5,1
];

include_once dirname(__DIR__) . DIRECTORY_SEPARATOR ."xhprof.php";
$xhprof = new Xhprof();
foreach ($datas as $data){
    var_dump($data);

    $obj = new Solution();
    $result = $obj->nextPermutation($data);
    var_dump($result);
    echo str_repeat("<br>", 3);
}
$xhprof->end();
